/**
 * 
 */
package com.csair.youth.constant;

import java.io.File;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * @author mickey
 *
 */
public class ResourceConstant {
	private static final Logger log = Logger.getLogger(ResourceConstant.class);
	private static ResourceConstant instance = new ResourceConstant();
	//upload attributes
	private static final String DETAULT_UPLOAD_TMP_PATH = "D:"+File.separator+"youth_tmp_upload";	//未审核路径
	private static final String DEFAULT_UPLOAD_STORE_PATH = "D:"+File.separator+"youth_store";	//供下载路径
	
	private String uploadTmpPath = null;
	private String uploadStorePath = null;
	
	public static ResourceConstant getInstance(){
		return instance;
	}
	
	public String getUploadTmpPath(){
		if(uploadTmpPath == null){
			Properties prop = new Properties();
			try {
				prop.load(this.getClass().getClassLoader().getResourceAsStream("properties/config_dev.properties"));
				uploadTmpPath = prop.getProperty("server.upload.tmpPath");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				log.error("读取properties文件出错");
				uploadTmpPath = DETAULT_UPLOAD_TMP_PATH;
				e.printStackTrace();
			}
		}
		return uploadTmpPath;
	}
	
	public String getUploadStorePath(){
		if(uploadStorePath == null){
			Properties prop = new Properties();
			try {
				prop.load(this.getClass().getClassLoader().getResourceAsStream("properties/config_dev.properties"));
				uploadStorePath = prop.getProperty("server.upload.storePath");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				log.error("读取properties文件出错");
				uploadStorePath = DEFAULT_UPLOAD_STORE_PATH;
				e.printStackTrace();
			}
		}
		return uploadStorePath;
	}
}
